home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume10 / logo / part05 < prev    next >
Encoding:
Internet Message Format  |  1987-06-23  |  37.2 KB

  1. Path: uunet!rs
  2. From: rs@uunet.UU.NET (Rich Salz)
  3. Newsgroups: comp.sources.unix
  4. Subject: v10i025: Logo interpreter for Unix, Part05/06
  5. Message-ID: <451@uunet.UU.NET>
  6. Date: 24 Jun 87 20:21:58 GMT
  7. Organization: UUNET Communications Services, Arlington, VA
  8. Lines: 841
  9. Approved: rs@uunet.uu.net
  10.  
  11. Submitted by: Brian Harvey <bh@mit-amt>
  12. Mod.Sources: Volume 10, Number 25
  13. Archive-Name: logo/Part05
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then unpack
  17. # it by saving it into a file and typing "sh file".  To overwrite existing
  18. # files, type "sh file -c".  You can also feed this as standard input via
  19. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  20. # will see the following message at the end:
  21. #        "End of archive 5 (of 6)."
  22. # Contents:  logoman.1
  23. # Wrapped by rsalz@pineapple.bbn.com on Wed Jun 24 14:27:00 1987
  24. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  25. if test -f logoman.1 -a "${1}" != "-c" ; then 
  26.   echo shar: Will not over-write existing file \"logoman.1\"
  27. else
  28. echo shar: Extracting \"logoman.1\" \(35585 characters\)
  29. sed "s/^X//" >logoman.1 <<'END_OF_logoman.1'
  30. X.ll 7.5i
  31. X.lt 7.5i
  32. X.po .2i
  33. X.pn 1
  34. X.de TL
  35. X.sp 2
  36. X.ft 3
  37. X.ce
  38. X\\$1
  39. X.sp 1
  40. X.ft 1
  41. X..
  42. X.de PP
  43. X.sp 1
  44. X.ti 5
  45. X.fi
  46. X.ft 1
  47. X..
  48. X.de NB
  49. X.de NP
  50. X'sp 1
  51. X.tl ''%''
  52. X'bp +1
  53. X'sp 2
  54. X\\..
  55. X.ch NP -1i
  56. X..
  57. X.de NP
  58. X'bp +1
  59. X'sp 2
  60. X..
  61. X.wh -1.0i NP
  62. X.TL "LSRHS Logo Manual"
  63. X.NB
  64. X.de EX
  65. X.ft 3
  66. X.in +5
  67. X.sp 1
  68. X.nf
  69. X..
  70. X.de EE
  71. X.ft 1
  72. X.in -5
  73. X.fi
  74. X.PP
  75. X..
  76. X.de EC
  77. X.ft 1
  78. X.in -5
  79. X.sp 1
  80. X.fi
  81. X..
  82. X.de IN
  83. X.br
  84. X.in +5
  85. X..
  86. X.de OU
  87. X.sp 1
  88. X.in -5
  89. X..
  90. X.de UB
  91. X.uf 3
  92. X.cu 1
  93. X\\$1
  94. X.ft 1
  95. X.uf 2
  96. X..
  97. X.PP
  98. X.UB "Introduction."
  99. XLogo is a computer programming language which was
  100. Xdesigned to be both simple to use and extremely powerful.  It was
  101. Xdesigned by a group of computer scientists at MIT and at Bolt, Beranek, and
  102. XNewman.  Its structure is based largely on the LISP language, which is
  103. Xwidely used in Artificial Intelligence research, but the notation has been
  104. Xchanged to make Logo far easier for a beginner than LISP.  This manual
  105. Xdescribes a version of Logo for the PDP-11, originally written in C at the
  106. XBoston Children's Museum and extensively modified at the Lincoln-Sudbury
  107. XRegional High School.
  108. X.PP
  109. XThe power of Logo comes primarily from the idea of the \f2procedure\f1.  A
  110. Xprocedure is simply something the computer "knows" how to do; some
  111. Xprocedures are built into Logo itself (these are called \f2primitive\f1
  112. Xprocedures), while others are \f2defined\f1 by the programmer in terms of
  113. Xthese simple procedures.  Defined procedures can be used as part of the
  114. Xdefinition of other procedures, so that a complicated program can be built
  115. Xin "layers" of complexity.  This layered structure is analogous to the
  116. Xdescription of a complex machine in terms of building blocks: an automobile
  117. Xis made of a chassis, a drive train, an electrical system, and so on.  The
  118. Xdrive train contains an engine, a transmission, a clutch, an axle, and so
  119. Xon.  The transmission contains a housing, gears, and levers.  A lever may
  120. Xinclude connecting joints at the ends and at a pivot point.  Eventually the
  121. Xdescription of the automobile reaches the level of bolts and washers; these
  122. Xcorrespond to the primitive procedures in Logo.
  123. X.PP
  124. X.UB "Starting Logo."
  125. XUse the shell command \f3logo\f1 to start the Logo
  126. Xinterpreter.  When Logo is running it will print a question mark (?) at the
  127. Xbeginning of a line to indicate that it is ready for you to type in a Logo
  128. Xinstruction.  The instruction may print something on the terminal, or draw a
  129. Xline on a graphics display screen, or move a turtle around the floor.  Then
  130. Xanother question mark is typed and you may give another instruction.  (If Logo
  131. Xprints a "greater than" sign (>) instead of a question mark, it is
  132. Xin \f2procedure definition mode\f1,
  133. Xwhich will be described later.  Type your system quit character
  134. X(control-G at Lincoln-Sudbury) to return to normal mode.)
  135. X.PP
  136. XIf an argument is used with the shell command \f3logo\f1, the argument is
  137. Xtaken as the name of a procedure, which Logo runs before doing anything
  138. Xelse.  You can therefore create a shell script which will start Logo, run
  139. Xa procedure automatically, and (if you say "goodbye" at the end of the
  140. Xprocedure) exit.
  141. X.PP
  142. X.UB "Syntax."
  143. XUnlike most computer languages, Logo has an almost
  144. Xentirely uniform
  145. Xsyntax.  That is, all of the different commands Logo understands are
  146. Xrepresented using the same notation: the name of a procedure is followed by
  147. Xits \f2inputs\f1, which may be \f2constants\f1 (like numbers) or else may
  148. Xbe the results of using other procedures.  Here is a simple example:
  149. X.EX
  150. Xprint "hello
  151. X.EC
  152. XIn this Logo instruction, the primitive procedure \f3print\f1 is used with
  153. Xa constant input, the word \f3hello\f1.  The quotation mark indicates that
  154. X\f3hello\f1 is being used to represent the word itself; without the
  155. Xquotation mark it would have been interpreted as the name of a procedure,
  156. Xjust as \f3print\f1 is the name of a procedure.  In Logo, the \f3print\f1
  157. Xprocedure always requires exactly one input, which is the thing to print.  The
  158. Xinput can be a \f2word\f1, as in this example, or a \f2list\f1, which will
  159. Xbe explained later.  (A \f2number\f1 is a special case of a word, and a
  160. X\f2sentence\f1 is a special case of a list.)  Here is another example:
  161. X.EX
  162. Xprint first "hello
  163. X.EC
  164. XIn this instruction, the primitive procedure \f3first\f1 is used.  This
  165. Xprocedure takes one input, a word, and has an \f2output\f1 which is the
  166. Xfirst letter of the word.  The output from \f3first\f1 is used as the input
  167. Xto \f3print\f1, so what is printed is the letter \f3h\f1 rather than the
  168. Xword \f3hello\f1 as in the earlier example.
  169. X.PP
  170. XDon't confuse the \f2output\f1 from a procedure with what is \f2printed\f1
  171. Xby the \f3print\f1 command.  In Logo, the word "output" is not used to
  172. Xrefer to what is printed by a program, just as the word "input" does not
  173. Xmean something you type into the program.  Instead, these words refer to
  174. Xobjects (words or lists) which are given to a procedure (inputs) or
  175. Xproduced by a procedure (outputs).  A particular procedure has a fixed
  176. Xnumber of inputs and outputs.  The number of inputs may be anything,
  177. Xincluding zero, whereas the number of outputs is either zero or one.  A
  178. Xprocedure with an output (like \f3first\f1) is called an \f2operation\f1; one
  179. Xwithout an output (like \f3print\f1) is called a \f2command\f1.
  180. X.PP
  181. XSome operations only have two possible outputs: the word \f3true\f1 and
  182. Xthe word \f3false\f1.  Such a procedure is called a \f2predicate\f1.  Predicates
  183. Xare used to allow a program to carry out some instruction only if a
  184. Xparticular condition is met.  By convention, predicates generally have
  185. Xnames ending with the letter "p".
  186. X.PP
  187. X.UB "Multiple inputs to operations."
  188. XSeveral Logo primitive procedures are
  189. Xoperations with two inputs.  The arithmetic operations, like \f3sum\f1, are
  190. Xexamples of this.  A special extension to Logo syntax allows such an operation
  191. Xto have more than two inputs by enclosing the operation and its inputs in
  192. Xparentheses or braces:
  193. X.EX
  194. X(sum 2 5 13 8.5)
  195. X.EC
  196. XAssociation is right to left.  At least two inputs must be given, except for
  197. Xthe \f3list\f1 operation, which can take one input if parenthesized.
  198. X.PP
  199. X.UB "Multi-instruction lines."
  200. XIt is possible to put more than one instruction on the same line when you
  201. Xare typing to Logo.  If you do this, it is recommended that you type a
  202. Xsemicolon (;) between the instructions for improved readability:
  203. X.EX
  204. Xprint "hello; print "goodbye
  205. X.EC
  206. XFor compatibility with other versions of Logo, it is permitted to leave out
  207. Xthe semicolon.  Later in this manual, the phrase "instruction line" will
  208. Xmean one or more instructions on a line.
  209. X.PP
  210. X.UB "Multi-line instructions."
  211. XIt is possible to continue an instruction on
  212. Xa second line.  To do this, end the first line with a backslash (\\),
  213. Ximmediately followed by the RETURN key.  If you are typing a quoted word,
  214. Xyou must end the word (with a space, for example) before using the
  215. Xbackslash-RETURN combination.  Inside a quoted word, backslash-RETURN
  216. Xmeans to put an actual RETURN as part of the word.
  217. X.PP
  218. X.UB "Comments."
  219. XIt is possible to include in an instruction line comments
  220. Xwhich are meant for human readers of your program (including yourself, next
  221. Xweek), and which are not Logo instructions.  To do this, begin the comment
  222. Xwith an exclamation point (!).  Everything after the exclamation point on the
  223. Xline will be ignored by Logo.  For example:
  224. X.EX
  225. Xprint [Hi, there.] ! A friendly greeting.
  226. X.EC
  227. XHowever, the exclamation point does not begin a comment if it is part of a
  228. Xword or list (see below).  You should type a space before the exclamation
  229. Xpoint, as in the example above, to make sure it will be interpreted as the
  230. Xbeginning of a comment.
  231. X.PP
  232. X.UB "Words."
  233. XEvery computer language deals with particular kinds
  234. Xof objects.  Most languages, like FORTRAN or BASIC or Pascal, are best at
  235. Xdealing with numbers.  Logo is a \f2list processing\f1 language, which is
  236. Xat its best with more complicated data structures.  The two main categories
  237. Xof object are the \f2word\f1 and the \f2list\f1.
  238. X.PP
  239. XA \f2word\f1 is a string of characters.  (A \f2character\f1 is a letter,
  240. Xdigit, space, or punctuation mark.  Things like TAB and RETURN on the
  241. Xterminal keyboard are also characters, although they are not usually used
  242. Xas part of Logo words.)  A word can be any length, including zero.  The way
  243. Xto indicate a word as part of a Logo program is to use the quotation mark
  244. X(") before the word.  The word begins with the character after the
  245. Xquotation mark and continues until a space, a tab, the end of the
  246. Xline, or one of these characters:
  247. X.EX
  248. X( ) [ ] { } " ;
  249. X.EC
  250. XA quotation mark immediately followed by a space or one of the other
  251. Xword-terminating characters indicates the \f2empty word\f1, which is a word
  252. Xof length zero.
  253. X.PP
  254. XPlease notice that, unlike most programming languages, Logo does not use
  255. Xquotation marks in pairs to delimit strings of characters.  The following
  256. Xinstruction is an error:
  257. X.EX
  258. Xprint "aardvark"
  259. X.EC
  260. XThis is an error because the \f3print\f1 command is followed by \f2two\f1
  261. Xwords, the word \f3aardvark\f1 and an empty word which is indicated by the
  262. Xsecond quotation mark.  Since \f3print\f1 only uses one input, the second
  263. Xword has no purpose, and Logo gives the error message
  264. X.EX
  265. XYou don't say what to do with "
  266. X.EE
  267. XIn order to include one of the word-terminating characters in a word, you
  268. Xmust precede it with a backslash (\\).  Do not confuse backslash with the
  269. Xregular slash (/) character.  For example, this instruction:
  270. X.EX
  271. Xprint "\\(boo\\)
  272. X.EC
  273. Xwill print the five characters \f3(boo)\f1 as its result.  The space
  274. Xcharacter may be included in a word by using a percent (%) instead of the
  275. Xspace.  Therefore, the following are equivalent:
  276. X.EX
  277. Xprint "Hello%there.
  278. Xprint "Hello\\ there.
  279. X.EC
  280. XTo include a percent character or a backslash character in a word, you must
  281. Xprecede it with a backslash.
  282. X.PP
  283. X.UB "Numbers."
  284. XA number is a special case of a word, in which the
  285. Xcharacters are all digits.  (That definition isn't quite complete, and will
  286. Xbe expanded in the next paragraph.)  A number need not be preceded with a
  287. Xquotation mark.  (This rule is possible because normally Logo interprets
  288. Xwords without quotation marks as the names of procedures, but there are no
  289. Xprocedures whose names begin with digits.)  If a quotation mark is not
  290. Xused, then any nondigit terminates the word.
  291. X.PP
  292. XActually, numbers may be written in scientific notation.  That is, they can
  293. Xinclude signs, decimal points, and a power of 10 by which the number is
  294. Xmultiplied.  This \f2exponent\f1 is indicated by the letter \f3e\f1
  295. Xfollowed by the integer power of 10.  The following numbers have the
  296. Xsame value:
  297. X.EX
  298. X1000
  299. X"1000
  300. X1000.00
  301. X1e3
  302. X10.0e+2
  303. X"+1.0e3
  304. X10000e-1
  305. X.EC
  306. XNotice that if the number begins with a sign it must be quoted.  A quoted
  307. Xnumber still must begin with a digit or a sign, not with a
  308. Xdecimal point or a letter \f3e\f1.  (The
  309. Xletter may be a capital \f3E\f1, by the way.)  If a number is quoted, it
  310. Xmust end with one of the normal word-terminating characters.  A number
  311. Xwhich contains only digits (no decimal point or exponent) is called
  312. Xan \f2integer\f1.  Note that a number with a decimal point is not
  313. Xconsidered an integer even if the digits after the decimal point are
  314. Xall zero.
  315. X.PP
  316. XSince a number is a word, the usual character-manipulating procedures may
  317. Xbe applied to it.  For example,
  318. X.EX
  319. Xprint first 1024
  320. X.EC
  321. Xprints the digit \f31\f1 which is the first character of the number.  In
  322. Xaddition, there are arithmetic procedures which apply specifically to numbers:
  323. X.EX
  324. Xprint sum 3 2
  325. X.EC
  326. Xprints the number 5.  These procedures will be listed later.
  327. X.PP
  328. X.UB "Lists."
  329. XA word can be thought of as a list of characters; for
  330. Xexample, the word \f3hello\f1 is a list of five letters.  In Logo it is
  331. Xpossible to manipulate not only lists of characters but also lists of
  332. Xwords, lists of lists of words, and so on.  This is a very powerful capability
  333. Xwhich allows very complicated data structures to be manipulated easily.  To
  334. Xindicate a list in a program, you put square brackets ([ and ]) around the
  335. Xlist, and separate the list elements with spaces.  For example:
  336. X.EX
  337. Xprint [This is a list of seven words.]
  338. X.EC
  339. XA list all of whose elements are words is called a \f2sentence\f1.  Here
  340. Xis an example of a list which is not a sentence:
  341. X.EX
  342. Xprint [[This is a list][of two sentences.]]
  343. X.EE
  344. XWithin a bracketed list, square brackets delimit sub-lists (lists which are
  345. Xelements of the main list).  The quotation mark, parentheses, and braces
  346. Xare not considered special within a bracketed list, unlike the rules for
  347. Xquoted words.  A list may extend over more than one line; that is, if you
  348. Xhave typed an open square bracket ([) and have not yet typed the matching
  349. Xclose square bracket, the Logo instruction is not ended by typing the RETURN
  350. Xkey.
  351. X.PP
  352. X.UB "Variables."
  353. XA variable is an entity which has a \f2name\f1, which
  354. Xis a word, and a \f2thing\f1 (also called a \f2value\f1), which
  355. Xcan be any Logo object.  Variables
  356. Xare used to "remember" a computed object for repeated or delayed use
  357. Xin a program.  In Logo, the most common way that a variable acquires
  358. Xa value is that it is associated with an input to a user-written
  359. Xprocedure.  In the following example, don't worry about the details
  360. Xof the format of the procedure, which will be explained later:
  361. X.EX
  362. Xto pff :sentence
  363. Xprint first first :sentence
  364. Xend
  365. X.EC
  366. XThis is the definition of a command with one input.  The name of the
  367. Xcommand is \f3pff\f1.  It has one input because in the "title line" (the
  368. Xone starting \f3to pff\f1) there is one variable name after the command
  369. Xname.  The variable whose name is \f3sentence\f1 is associated with the
  370. Xfirst (and only, in this case) input to \f3pff\f1.  In the line starting
  371. Xwith the word \f3print\f1, the notation \f3:sentence\f1 means "the \f2thing\f1
  372. Xof the variable whose \f2name\f1 is \f3sentence\f1".  (To refer to the
  373. Xname itself, quote it as you would any word.)  If this procedure is used
  374. Xin a Logo instruction like this:
  375. X.EX
  376. Xpff [This is the poop.]
  377. X.EC
  378. Xthen the variable \f3sentence\f1 has the value \f3[This is the poop.]\f1.
  379. X.PP
  380. XIt is also possible to assign a value to a variable by an explicit
  381. XLogo instruction.  There is a primitive procedure to do this:
  382. X.sp 1
  383. X\f3make\f1 \(em Command, two inputs.
  384. X.IN
  385. XThe first input is the name of a variable (that is, it must be a word); the
  386. Xsecond is any Logo object.  The effect of the command is to assign the
  387. Xsecond input as the value of the variable named by the first input.
  388. X.OU
  389. XIf you are accustomed to programming in a non-procedural language like
  390. XBASIC, you should strenuously avoid the temptation to overuse \f3make\f1;
  391. Xexplicit assignment is almost always the wrong thing to do in Logo.  Total
  392. Xabstention is the best policy for a Logo beginner.
  393. X.PP
  394. XIn Logo, variables are \f2dynamically scoped\f1.  That means that a
  395. Xvariable can "belong to" a particular procedure; such a variable can
  396. Xbe used by that procedure and by any procedure which is used by an
  397. Xinstruction within the procedure, but is not available to the procedure
  398. Xwhich invoked the owning procedure.  In other words, such a \f2local\f1
  399. Xvariable comes into being when the owning procedure starts running, and
  400. Xdisappears when that procedure is finished.  It is possible for a
  401. Xprocedure with a local variable to use another procedure with a local
  402. Xvariable of the same name.  In that case, the variable belonging to the
  403. X"inner" procedure is the one which is associated with the name as long
  404. Xas it exists; when the inner procedure is finished, the "hidden"
  405. Xvariable belonging to the outer procedure is again available.
  406. X.PP
  407. XA variable which is associated with the input to a procedure is
  408. Xautomatically local to that procedure.  Other variables are normally
  409. X\f2global\f1: they are "permanent" and do not disappear when the
  410. Xprocedure in which they get their values finish.  It is both possible
  411. Xand desirable to make such variables local, by an explicit instruction
  412. Xto that effect:
  413. X.sp 1
  414. X\f3local\f1 \(em Command, one input.
  415. X.IN
  416. XThe input must be a word.  A variable with that word as its name
  417. Xis created, local to the currently running procedure (that is,
  418. Xlocal to the procedure in which the \f3local\f1 command is used).
  419. X.OU
  420. XThe virtue of local variables is that they make procedures more
  421. Xindependent of one another than they would be if global variables
  422. Xwere used.  In other words, if you use local variables consistently,
  423. Xthen nothing that happens in one procedure will change the values
  424. Xof variables used in another procedure.  This makes it very much
  425. Xeasier to find program errors.
  426. X.PP
  427. X.UB "Case insensitivity."
  428. XNames of procedures (primitive or user-defined) and names of variables
  429. Xmay be typed in upper or lower case.  They are converted internally to
  430. Xlower case.  That is, the variables \f3foo\f1 and \f3FOO\f1 are the
  431. Xsame variable.  Letters in other contexts are not converted to lower
  432. Xcase.  For example, \f3equalp\f1 will report that the words \f3foo\f1
  433. Xand \f3FOO\f1 are not equal.
  434. X.PP
  435. XNames of procedures and names of variables may include only letters,
  436. Xdigits, and the special characters period (.) and underscore (_).  Also,
  437. Xnames of procedures are limited to 11 characters in some versions of Unix.
  438. X.PP
  439. X.UB "Primitive procedures to define user procedures."
  440. XThere are
  441. Xtwo ways to define your own procedure.  The first way, using the \f3to\f1
  442. Xcommand, is simple to learn but limited in flexibility.  The second way,
  443. Xusing the \f3edit\f1 command, is more complicated to learn, but makes it
  444. Xeasy to make changes in your procedures.  The \f3edit\f1 command uses the
  445. Xtext editing program \f3edt\f1, just as you might use it outside of Logo
  446. Xto edit a document you want to print.  Once you've learned the special
  447. Xediting commands in \f3edt\f1, it's easy to use.  The \f3to\f1 command makes
  448. Xit possible to begin programming in Logo without having learned how to use
  449. X\f3edt\f1.  It just lets you type in your procedure definition, without any
  450. Xprovision for correcting errors or changing the definition of the procedure.
  451. XIt is fast and convenient for short procedures, but limited.
  452. X.sp 1
  453. XThe \f3to\f1 command is unique, in Logo, in that its inputs are interpreted
  454. Xin a special way.  The inputs aren't \f2evaluated\f1: Logo doesn't run any
  455. Xprocedures you name, or look up the values of any variables, before carrying
  456. Xout the \f3to\f1 command.  The example below should make this clearer.
  457. X.sp 1
  458. X\f3to\f1 \(em Command, special form, see below.
  459. X.IN
  460. XThis command takes a variable number of inputs.  The first is the name
  461. Xof a procedure to be defined.  The rest, if any, must be preceded by
  462. Xcolons, and are the names of variables to be used as inputs to the
  463. Xprocedure.  Logo responds to the \f3to\f1 command by printing a
  464. X"greater than" sign (>) prompt, to show you that you are defining a procedure
  465. Xrather than entering commands to be executed immediately.  You type
  466. Xthe instruction lines which make up the definition.  When
  467. Xyou are done with the definition, type the special word \f3end\f1 on
  468. Xa line by itself.  For example:
  469. X.sp 1
  470. X.nf
  471. X\f3\z_?to twoprint :thing
  472. X\z_>print :thing
  473. X\z_>print :thing
  474. X\z_>end
  475. X\z_?\f1
  476. X.fi
  477. X.sp 1
  478. XThis example shows the definition of a procedure named \f3twoprint\f1,
  479. Xwhich has one input, named \f3thing\f1.  The procedure you are defining
  480. Xwith the \f3to\f1 command must not already be defined.
  481. X.OU
  482. X\f3edit\f1 \(em Command, zero or one input.  Abbreviation: \f3ed\f1
  483. X.IN
  484. XThe input to this command must be a word, which is the name of a procedure,
  485. Xor a list of words, each of which is the name of a procedure.
  486. X(Unlike the \f3to\f1 command, but like all other Logo procedures, the
  487. X\f3edit\f1 command evaluates its input, so you must use a quotation mark
  488. Xbefore the procedure name, if only one is given, to indicate
  489. Xthat it is the name itself which is
  490. Xthe input to \f3edit\f1; otherwise Logo would actually run the procedure
  491. Xto calculate the input to \f3edit\f1.)  The procedure you name may or may
  492. Xnot already be defined.  Logo responds to the \f3edit\f1 command by running
  493. Xthe text editor \f3edt\f1, editing the definition of the procedure(s) named in
  494. Xits input.  (If a procedure was not previously defined, Logo creates an
  495. Xinitial definition for it which contains only a title line and the end line.)
  496. XYou then edit the definition(s) with \f3edt\f1.  When you write the file and
  497. Xleave \f3edt\f1, Logo will use the edited file as the definition(s) of the
  498. Xprocedure(s).  You must not put anything in the file except procedure
  499. Xdefinitions; in other words, every nonempty line in the file must be between
  500. Xa "to" line and an "end" line.
  501. X.sp 1
  502. XIf the \f3edit\f1 command is given with no input, \f3edt\f1 is given the same
  503. Xfile as from the last time you used the \f3edit\f1 command.  This is a
  504. Xconvenience for editing the same procedure(s) repeatedly.
  505. X.sp 1
  506. XIf, while editing, you change your mind and want to leave \f3edt\f1
  507. Xwithout redefining anything, use the command \f3ESC ^Z\f1 instead of
  508. Xthe normal \f3^Z\f1.  This special way of leaving \f3edt\f1 tells Logo
  509. Xnot to redefine your procedures.  You have the choice, before exiting
  510. X\f3edt\f1, of writing or not writing the temporary file which contains
  511. Xthe definitions.  If you don't write the file, another \f3edit\f1 command
  512. Xwith no input will re-read the previous contents of the temporary file;
  513. Xif you do, another \f3edit\f1 will re-read the new version.
  514. X.sp 1
  515. XIf your Unix environment contains a variable named EDITOR, the contents of
  516. Xthat variable is used as the name of the text editor program instead of
  517. Xthe standard \f3edt\f1.  The variable can contain a full pathname, or just
  518. Xa program name if the program can be found in /bin or /usr/bin.  Your favorite
  519. Xeditor may not have a facility like \f3edt\f1's ESC ^Z to abort redefinition.
  520. X.OU
  521. X\f3show\f1 \(em Command, one input.  Abbreviation: \f3po\f1
  522. X.IN
  523. XThe input to this command is a word or a list of words.  Each word must be
  524. Xthe name of a procedure.  The command prints out the definition(s) of the
  525. Xprocedure(s) on your terminal.  (The abbreviation \f3po\f1 stands for
  526. X\f3printout\f1, which is the name used for this command in some other versions
  527. Xof Logo.)
  528. X.OU
  529. X\f3pots\f1 \(em Command, no inputs.
  530. X.IN
  531. XThis command types at your terminal the title lines of all procedures
  532. Xyou've defined.  The name is an abbreviation for "print out titles".
  533. X.OU
  534. X\f3erase\f1 \(em Command, one input.  Abbreviation: \f3er\f1
  535. X.IN
  536. XAs for the \f3show\f1 command, the input is either a word, naming one
  537. Xprocedure, or a list of words, naming more than one.  The named procedures
  538. Xare erased, so that they are no longer defined.
  539. X.OU
  540. X.ti 5
  541. X.UB "Primitive procedures to manipulate words and lists."
  542. XThere are
  543. Xprimitive procedures to print text objects on the terminal, to read
  544. Xthem from the terminal, to combine them into larger objects, to split
  545. Xthem into smaller objects, and to determine their size and nature:
  546. X.sp 1
  547. X\f3print\f1 \(em Command, one input.  Abbreviation: \f3pr\f1
  548. X.IN
  549. XThe input, which may be a word or a list, is printed on the terminal,
  550. Xfollowed by a new line character.  (That is, the terminal is positioned
  551. Xat the beginning of a new line after printing the object.)  If the
  552. Xobject is a list, any sub-lists are delimited by square brackets, but
  553. Xthe entire object is not delimited by brackets.
  554. X.OU
  555. X\f3type\f1 \(em Command, one input.
  556. X.IN
  557. XThe input, which may be a word or a list, is printed on the terminal,
  558. X\f2without\f1 a new line character.  (That is, the terminal remains
  559. Xpositioned at the end of the object after printing it.)  Brackets
  560. Xare used as with the \f3print\f1 command.
  561. X.OU
  562. X\f3fprint\f1 \(em Command, one input.  Abbreviation: \f3fp\f1
  563. X.IN
  564. XThe input is printed as by the \f3print\f1 command, except that if it
  565. Xis a list (as opposed to a word) it is enclosed in square brackets.  The
  566. Xname of the command is short for "full print".
  567. X.OU
  568. X\f3ftype\f1 \(em Command, one input.  Abbreviation: \f3fty\f1
  569. X.IN
  570. XThe input is printed as by the \f3type\f1 command, except that if it
  571. Xis a list, it is enclosed in square brackets.
  572. X.OU
  573. X\f3readlist\f1 \(em Operation, no inputs.  Abbreviation: \f3rl\f1
  574. X.IN
  575. XLogo waits
  576. Xfor a line to be typed by the user.  The contents of the line are made
  577. Xinto a list, as though typed within square brackets as part of a Logo
  578. Xinstruction.  (The user should not actually type brackets around the
  579. Xline, unless s/he desires a list of one element, which is a list
  580. Xitself.)  That list is the output from the operation.
  581. X.OU
  582. X\f3request\f1 \(em Operation, no inputs.
  583. X.IN
  584. XA question mark is printed on the terminal as a prompt.  Then Logo waits
  585. Xfor a line to be typed by the user, as for \f3readlist\f1.
  586. X.OU
  587. X\f3word\f1 \(em Operation, two inputs.
  588. X.IN
  589. XThe two inputs must be words.  The output is a word which is the
  590. Xconcatenation of the two inputs.  There is no space or other
  591. Xseparation of the two inputs in the output.
  592. X.OU
  593. X\f3sentence\f1 \(em Operation, two inputs.  Abbreviation: \f3se\f1
  594. X.IN
  595. XThe two inputs may be words or lists.  The output is a list formed
  596. Xfrom the two inputs in this way: if either input is a word, that
  597. Xword becomes a member of the output list; if either input is a
  598. Xlist, the \f2members\f1 of that input become members of the
  599. Xoutput.  Here are some examples:
  600. X.EX
  601. X.ta 2i 4i
  602. Xfirst input    second input    output
  603. X"hello    "test    [hello test]
  604. X"goodbye    [cruel world]    [goodbye cruel world]
  605. X[a b]    [c d]    [a b c d]
  606. X[]    "garply    [garply]
  607. X.EC
  608. XIf an input is the empty list, as in the last example above, it
  609. Xcontributes nothing to the output.
  610. X.OU
  611. X\f3list\f1 \(em Operation, two inputs.
  612. X.IN
  613. XThe output is a list of two elements, namely, the two inputs.  The
  614. Xinputs may be words or lists.
  615. X.OU
  616. X\f3fput\f1 \(em Operation, two inputs.
  617. X.IN
  618. XThe first input may be any Logo object; the second must be a list.  The
  619. Xoutput is a list which is identical with the second input except that
  620. Xit has an extra first member, namely, the first input.
  621. X.OU
  622. X\f3lput\f1 \(em Operation, two inputs.
  623. X.IN
  624. XThe first input may be any Logo object; the second must be a list.  The
  625. Xoutput is a list which is identical with the second input except that
  626. Xit has an extra last member, namely, the first input.
  627. X.OU
  628. X\f3first\f1 \(em Operation, one input.
  629. X.IN
  630. XThe input may be any non-empty Logo object.  If the input is a list,
  631. Xthe output is its first member.  If the input is a word, the output is
  632. Xa single-letter word, namely the first letter of the input.  If the
  633. Xinput is empty (a word or list of length zero) an error results.
  634. X.OU
  635. X\f3last\f1 \(em Operation, one input.
  636. X.IN
  637. XThe input may be any non-empty Logo object.  If the input is a list,
  638. Xthe output is its last member.  If the input is a word, the output is
  639. Xa single-letter word, namely the last letter of the input.  If the
  640. Xinput is empty (a word or list of length zero) an error results.
  641. X.OU
  642. X\f3butfirst\f1 \(em Operation, one input.  Abbreviation: \f3bf\f1
  643. X.IN
  644. XThe input may be any non-empty Logo object.  If the input is a list,
  645. Xthe output is a list equal to the input list with the first member
  646. Xremoved.  (If the input list has only one member, the output is
  647. Xthe \f2empty list\f1, a list of zero members.)  If the input is
  648. Xa word, the output is a word equal to the input word with the
  649. Xfirst letter removed.  (If the input is a single-letter word, the
  650. Xoutput is the \f2empty word\f1.)  If the input is empty, an
  651. Xerror results.
  652. X.OU
  653. X\f3butlast\f1 \(em Operation, one input.  Abbreviation: \f3bl\f1
  654. X.IN
  655. XThe input may be any non-empty Logo object.  If the input is a list,
  656. Xthe output is a list equal to the input list with the last member
  657. Xremoved.  (If the input list has only one member, the output is
  658. Xthe \f2empty list\f1, a list of zero members.)  If the input is
  659. Xa word, the output is a word equal to the input word with the
  660. Xlast letter removed.  (If the input is a single-letter word, the
  661. Xoutput is the \f2empty word\f1.)  If the input is empty, an
  662. Xerror results.
  663. X.OU
  664. X\f3count\f1 \(em Operation, one input.
  665. X.IN
  666. XThe input may be any Logo object.  If the input is a list, the
  667. Xoutput is a number indicating the number of members in the list.  (Note:
  668. Xonly top-level members are counted, not members of members.  The count
  669. Xof the list
  670. X.EX
  671. X[[This is] [a list]]
  672. X.EC
  673. Xis 2, not 4.)  If the input is a word, the output is the number of
  674. Xletters (or other characters) in the word.  Remember that in Logo a
  675. Xnumber is just a particular kind of word, so the output from \f3count\f1 can
  676. Xbe manipulated like any other Logo word.
  677. X.OU
  678. X\f3emptyp\f1 \(em Operation (predicate), one input.
  679. X.IN
  680. XThe input can be any Logo object.  The output is the word \f3true\f1 if
  681. Xthe input is of length zero (i.e., it is the empty word or the empty
  682. Xlist).  The output is the word \f3false\f1 otherwise.
  683. X.OU
  684. X\f3wordp\f1 \(em Operation (predicate), one input.
  685. X.IN
  686. XThe input can be any Logo object.  The output is the word \f3true\f1 if
  687. Xthe input is a word.  The output is the word \f3false\f1 if the input
  688. Xis a list.
  689. X.OU
  690. X\f3sentencep\f1 \(em Operation (predicate), one input.
  691. X.IN
  692. XThe input can be any Logo object.  The output is the word \f3true\f1 if
  693. Xthe input is a sentence, i.e., a list of words.  The output is the word
  694. X\f3false\f1 if the input is a word, or if any member of the input is a
  695. Xlist.
  696. X.OU
  697. X\f3is\f1 \(em Operation (predicate), two inputs.
  698. X.IN
  699. XThe inputs can be any Logo objects.  The output is the word \f3true\f1 if
  700. Xthe two inputs are identical.  That is, they must be of the same type
  701. X(both words or both lists), they must have the same count, and their
  702. Xmembers (if lists) or their characters (if words) must be identical.  The
  703. Xoutput is the word \f3false\f1 otherwise.  (Note: this is an exception
  704. Xto the convention that names of predicates end with the letter "p".)
  705. X.OU
  706. X\f3memberp\f1 \(em Operation (predicate), two inputs.
  707. X.IN
  708. XIf the second input is a word, the first input must be a word of
  709. Xlength one (a single character), and the output is \f3true\f1 if and
  710. Xonly if the first input is contained in the second as a character.  If
  711. Xthe second input is a list, the first input can be any Logo object,
  712. Xand the output is \f3true\f1 if and only if the first input is a member
  713. Xof the second input.  (Note that this is member, not subset.)
  714. X.OU
  715. X\f3item\f1 \(em Operation, two inputs.  Abbreviation: \f3nth\f1
  716. X.IN
  717. XThe first input must be a positive integer less than or equal to
  718. Xthe \f3count\f1 of the second input.  If the second input is a word,
  719. Xthe output is a word of length one containing the selected character
  720. Xfrom the word.  (Items are numbered from 1, not 0.)  If the second input
  721. Xis a list, the output is the selected member of the list.
  722. X.OU
  723. X.ti 5
  724. X.UB "Primitive procedures for turtles and graphics."
  725. XAn important
  726. Xpart of the Logo environment is a rich set of applications to which the
  727. Xcomputer can be directed.  The most important of these is \f2turtle
  728. Xgeometry\f1, a way of describing paths of motion in a plane which is
  729. Xwell-suited to computer programming.  There are two ways to use the
  730. Xturtle procedures.  First, you can control a \f2floor turtle\f1, a small
  731. Xrobot which can move one the floor or on a table under computer
  732. Xcontrol.  Second, you can use a \f2display turtle\f1 to draw pictures
  733. Xon the TV screen of a graphics terminal.
  734. X.PP
  735. XEach computer center has a different variety of graphics hardware
  736. Xavailable.  Floor turtles are very different from display turtles, but also
  737. Xeach kind of display terminal has different characteristics.  For example,
  738. Xsome terminals can draw in several colors; others can't.  The following
  739. Xdescriptions of graphics primitives explain the "best" case for each one
  740. Xand mention restrictions on some graphics devices.
  741. X.PP
  742. XThe floor turtle can draw pictures on paper, because it has a pen
  743. Xattached to its "belly": the underside of the turtle.  Since it is
  744. Xa mechanical device, however, it is not very precise; the pictures
  745. Xyou get may not be exactly like what your program specifies.  A more
  746. Xinteresting way to use the floor turtle is to take advantage of its
  747. X\f2touch sensors\f1.  Switches under the turtle's dome allow the computer
  748. Xto know when the turtle bumps into an obstacle.  You can use this
  749. Xinformation to write programs to get around obstacles or to follow
  750. Xa maze.
  751. X.PP
  752. XThe display turtle lives on the surface of a TV screen.  It can draw
  753. Xpictures more precisely than the floor turtle, since it does not
  754. Xmeasure distances and angles mechanically.  It is also faster than
  755. Xthe floor turtle.  When using the display turtle, remember that
  756. Xit interprets commands relative to its own position and direction,
  757. Xjust as the floor turtle does.  The command \f3left\f1, for example,
  758. Xturns the turtle to its own left, which may or may not be toward
  759. Xthe left side of the TV screen.
  760. X.sp 1
  761. X\f3turtle\f1 \(em Command, one input.  Abbreviation: \f3tur\f1
  762. X.IN
  763. XThe input is the name of a turtle.  You can only control one turtle
  764. Xat a time, so using this command a second time releases the turtle
  765. Xpreviously selected.  The names of floor turtles are numbers like
  766. X\f30\f1 and \f31\f1.  If you are using
  767. Xa graphics display terminal (not just a text display trminal), you can
  768. Xcontrol the display turtle by using the word \f3display\f1 (or the
  769. Xabbreviation \f3dpy\f1) as the turtle name.  (As usual, the word
  770. Xmust be preceded by a quotation mark.)  If you use a graphics primitive
  771. Xwithout selecting a turtle, Logo assumes that you want to use the
  772. Xdisplay turtle.  But once you select a floor turtle, you must say
  773. X\f3turtle "display\f1 explicitly to switch to the display.
  774. X.sp 1
  775. XThe word \f3off\f1 as input to the \f3turtle\f1 command releases a floor
  776. Xturtle, if you have one, or turns off the graphics display if you have
  777. Xbeen using the display turtle.  This also happens when you leave Logo.
  778. X.OU
  779. X\f3forward\f1 \(em Command, one input.  Abbreviation: \f3fd\f1
  780. X.IN
  781. XThe input is a number, the distance you would like the turtle
  782. Xto move.  For a floor turtle, the unit of distance is however
  783. Xfar the turtle can travel in 1/30 second.  For a display turtle,
  784. Xthe unit is one dot on the TV screen.  (Note: on some displays, one
  785. Xdot horizontally may not be the same length as one dot vertically.  The
  786. X\f3setscrunch\f1 command allows you to control the
  787. Xrelative sizes so that squares come out
  788. Xsquare.)  The turtle moves in whatever direction it is pointing
  789. Xwhen you use the command.
  790. X.OU
  791. X\f3back\f1 \(em Command, one input.  Abbreviation: \f3bk\f1
  792. X.IN
  793. XThe input is a number, a distance to move, as in the \f3forward\f1
  794. Xcommand.  The difference is that the turtle moves backward, i.e.,
  795. Xin the direction exactly opposite to the way it's pointing.
  796. X.OU
  797. X\f3left\f1 \(em Command, one input.  Abbreviation: \f3lt\f1
  798. X.IN
  799. XThe input is a number, the number of degrees of angle through
  800. Xwhich the turtle should turn counterclockwise.  This command
  801. Xdoes not change the \f2position\f1 of the turtle, but merely
  802. Xits \f2heading\f1 (the direction in which it points).  The
  803. Xturn will be only approximately correct for the floor turtle,
  804. Xbecause of mechanical errors.  For the display turtle, the
  805. Xangle will be perfectly reproducible, although it may not look
  806. Xquite right on the screen because of the difference in size
  807. Xbetween horizontal and vertical dots.  Nevertheless, a display
  808. Xturtle program will work in the sense that when the turtle is
  809. Xsupposed to return to its starting point, it will do so.
  810. X.OU
  811. X\f3right\f1 \(em Command, one input.  Abbreviation: \f3rt\f1
  812. X.IN
  813. XThe input is a number; the turtle turns through the specified
  814. Xnumber of degrees clockwise.
  815. X.OU
  816. X\f3penup\f1 \(em Command, no inputs.  Abbreviation: \f3pu\f1
  817. X.IN
  818. XThis command tells the turtle to raise its pen from the paper,
  819. Xso that it does not leave a trace when it moves.  In the case
  820. Xof the display turtle, there is no physical pen to move
  821. Xmechanically, but the effect is the same: any \f3forward\f1 or
  822. X\f3back\f1 commands after this point do not draw a line.  The
  823. Xfloor turtle starts with its pen up; the display turtle starts
  824. Xwith its pen down.  Note: the floor turtle will not move on
  825. Xthe carpet correctly with its pen down; put it on a smooth
  826. Xsurface if you want to draw pictures.
  827. X.OU
  828. END_OF_logoman.1
  829. if test 35585 -ne `wc -c <logoman.1`; then
  830.     echo shar: \"logoman.1\" unpacked with wrong size!
  831. fi
  832. # end of overwriting check
  833. fi
  834. echo shar: End of archive 5 \(of 6\).
  835. cp /dev/null ark5isdone
  836. MISSING=""
  837. for I in 1 2 3 4 5 6 ; do
  838.     if test ! -f ark${I}isdone ; then
  839.     MISSING="${MISSING} ${I}"
  840.     fi
  841. done
  842. if test "${MISSING}" = "" ; then
  843.     echo You have unpacked all 6 archives.
  844.     echo "Now see the README"
  845.     rm -f ark[1-9]isdone
  846. else
  847.     echo You still need to unpack the following archives:
  848.     echo "        " ${MISSING}
  849. fi
  850. ##  End of shell archive.
  851. exit 0
  852.